package com.example.springbootquartz.job;

import com.example.springbootquartz.dao.JobTestDao;
import com.example.springbootquartz.model.JobTest;
import com.example.springbootquartz.tools.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.sql.Timestamp;
import java.util.Date;
import java.util.UUID;

@Slf4j
public class NewJob extends QuartzJobBean {
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        JobTestDao jobTestDao = SpringUtils.getBean(JobTestDao.class);
        Date date = new Date();
        JobTest jobTest = new JobTest();
        jobTest.setId(UUID.randomUUID().toString());
        jobTest.setMessage("啊啊啊啊");
        jobTest.setCreateTime(new Timestamp(date.getTime()));
        jobTestDao.insertTest(jobTest);
        log.info(">>>>>>>>>>>>>>>>>>> 啊啊啊啊");
    }
}
